
//首页
function firstpage()
{
	if(pageNow!=1)
	{
		pageNow=1;
		var value=$("#searchtext").val();
		var department=$(".select_:selected").val();

		var mm='';
		if(Trim(value)!=""){
			mm+=Trim(value);
			if(department!="#"){
				mm+=';'+department;
			}
		}else{
			if(department!="#"){
				mm=department;
			}
		}

		ajax('../InformationAction','pageNow='+pageNow+"&target="+mm+'&category=' + category);

	}

}
//最后一页
function lastpage()
{
	if(pageNow!=pagecount)
	{
		pageNow=pagecount;
		var value=$("#searchtext").val();
		var department=$(".select_:selected").val();

		var mm='';
		if(Trim(value)!=""){
			mm+=Trim(value);
			if(department!="#"){
				mm+=';'+department;
			}
		}else{
			if(department!="#"){
				mm=department;
			}
		}

		ajax('../InformationAction','pageNow='+pageNow+"&target="+mm+'&category=' + category);


	}
}
//前一页
function prepage()
{
	if(pageNow!=1)
	{
		pageNow=pageNow-1;
		var value=$("#searchtext").val();
		var department=$(".select_:selected").val();

		var mm='';
		if(Trim(value)!=""){
			mm+=Trim(value);
			if(department!="#"){
				mm+=';'+department;
			}
		}else{
			if(department!="#"){
				mm=department;
			}
		}

		ajax('../InformationAction','pageNow='+pageNow+"&target="+mm+'&category=' + category);

	}
}
//后一页
function nextpage()
{

	if(pageNow!=pagecount)
	{
		pageNow=pageNow+1;

		var value=$("#searchtext").val();
		var department=$(".select_:selected").val();

		var mm='';
		if(Trim(value)!=""){
			mm+=Trim(value);
			if(department!="#"){
				mm+=';'+department;
			}
		}else{
			if(department!="#"){
				mm=department;
			}
		}

		ajax('../InformationAction','pageNow='+pageNow+"&target="+mm+'&category=' + category);

	}

}
//跳到多少页
function thepage(e)
{
	if(pageNow!=e)
	{
		pageNow=e;

		var value=$("#searchtext").val();
		var department=$(".select_:selected").val();

		var mm='';
		if(Trim(value)!=""){
			mm+=Trim(value);
			if(department!="#"){
				mm+=';'+department;
			}
		}else{
			if(department!="#"){
				mm=department;
			}
		}
		ajax('../InformationAction','pageNow='+pageNow+"&target="+mm+'&category=' + category);
	}
}
//跳转到多少页
function turntopage()
{
	var page=$(".turnpage").val();
	if(page.search(/^[1-9]{1,250}$/)==-1||parseInt(page)>pagecount){
		alert('请输入合法数字！');
		return;
	}


	if(page!=pageNow&&page<=pagecount&&page>=1)
	{
		pageNow=page;
		var value=$("#searchtext").val();
		var department=$(".select_:selected").val();

		var mm='';
		if(Trim(value)!=""){
			mm+=Trim(value);
			if(department!="#"){
				mm+=';'+department;
			}
		}else{
			if(department!="#"){
				mm=department;
			}
		}

		ajax('../InformationAction','pageNow='+pageNow+"&target="+mm+'&category=' + category);


	}
}
//异步获取数据，生成表格函数
function ajax(url,param){

	ajax_post(url,param,function(data){
		var table=$("#show");
		table.empty();
		var html='';
		var count=0;
		if(typeof data.pageCount){
			count=data.pageCount;
		};
		var len=data.list.length;//返回数据长度
		//alert(len);
		if(len!=0)
		{
			html="<tr bgcolor='#FFFFFF'>" +
			"<td height='24' colspan='10' >&nbsp;消息列表:&nbsp;</td>" +
			"</tr>" +
			"<tr align='center' bgcolor='#FFF8EE' height='22'>" +
			"<th width=''>选择</th>" +
			"<th width=''>ID</th>" +
			"<th width=''>标题</th>" +
			"<th width=''>关键字</th>" +
			"<th width='12%'>附件</th>" +
			"<th width='13%'>发布时间</th>" +
			"<th width='12%'>操作</th>" +
			"</tr>";
			for(var i=0;i<len;i++)
			{
				var message=data.list[i];
				var id=message.id;
				var title=message.title;
				var keywords=message.keywords;
				var file=message.file;
				var time=formatTime(new Date(message.time));

				html+="<tr align='center' id="+'id_'+id+" bgcolor='#FFFFFF' onMouseMove=this.bgColor='#FFEEB4' onMouseOut=this.bgColor='#FFFFFF' height='22' >" +
				"<td><input name='id' type='checkbox'  value="+id+" class='np'></td>" +
				"<td>"+id+"</td>"+
				"<td align='left'><a href='../preview.html?id="+id+"' target='main'>"+title+"</a></td>" +
				"<td>"+keywords+"</td>" +
				"<td>"+file+"</td>" +
				"<td>"+time+"</td>" +
				"<td><a href='updateInformation.html?id="+id+"' target='main' >编辑</a> | " +
				"<a href='javascript:;'  onclick='delone("+id+");'>删除</a> | " +
				"<a href='../preview.html?id="+id+"' target='main' >预览</a>" +
				"</td></tr>";
			}

			html+="<tr bgcolor='#FFFFFF'><td height='28' colspan='10'>&nbsp;" +
			"<input type='button' class='coolbg np'  id='selall' value='全选' onclick='selAll();'/>" +
			"<input type='button' class='coolbg np'  id='selall' value='取消'  onclick='noSelAll();'/>" +
			"<input type='button' class='coolbg np' onClick='javascript:location.reload();' value='更新' />" +
			"<input type='button' class='coolbg np' onClick='deleteall();' value='删除所选' />" +
			"</td></tr> ";
			html+=paging(pageNow,pagesize,count);
			table.append(html);
		}else{
			$('#table_1').html(''); //清空table1
			alert('抱歉，没有查找到任何记录!');
		}

	});
}
